package com.cv.platform.controller.platform.video;

import com.cv.framework.common.pojo.Result;
import com.cv.platform.service.video.CvVideoLikeService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.annotation.security.PermitAll;

/**
 * 视频平台 - 视频点赞控制层
 *
 * @author Charles_XDXD
 */
@Tag(name = "视频平台 - 视频点赞控制层")
@RestController
@RequestMapping("/platform/video/like")
public class CvVideoLikeController {

    @Resource
    private CvVideoLikeService cvVideoLikeService;

    @GetMapping("getLikeCount")
    @Operation(summary = "获取视频点赞数")
    @PermitAll
    public Result<Integer> getLikeCount(Long videoId) {
        return Result.success(cvVideoLikeService.getVideoLikeCount(videoId));
    }

    @GetMapping("getLikeStatus")
    @Operation(summary = "获取视频点赞状态")
    public Result<Boolean> getLikeStatus(Long videoId) {
        return Result.success(cvVideoLikeService.getVideoLikeStatus(videoId));
    }

    @PostMapping("saveLike")
    @Operation(summary = "保存视频点赞记录")
    public Result<Boolean> saveLike(Long videoId) {
        cvVideoLikeService.saveVideoLike(videoId);
        return Result.success(true);
    }

    @DeleteMapping("cancelLike")
    @Operation(summary = "取消视频点赞记录")
    public Result<Boolean> cancelLike(Long videoId) {
        cvVideoLikeService.cancelVideoLike(videoId);
        return Result.success(true);
    }

}
